//
//  ApiManager.m
//  RYMart
//
//  Created by iMac on 2017/10/30.
//  Copyright © 2017年 Jason. All rights reserved.
//

#define kCacheValue 1
#define CustomErrorDomain @"com.xlxsc.XinMart.ErrorDomain"
#import "ApiManager.h"
#import "APIConsts.h"
#import "RTMD5.h"
@implementation ApiManager
static ApiManager *apiManager;

#pragma mark -manager
+ (ApiManager *)ShardInstance {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        apiManager = [[ApiManager alloc] init];
    });
    return apiManager;
}

//登录
- (void)loginAccount:(NSString *)account password:(NSString *)password resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"account":account,
        @"pass":password
    };
    return [self requestDataWithUrl:Login parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//认证
- (void)authNmae:(NSString *)name iccard:(NSString *)iccard type:(NSString *)type resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"n":name,
        @"ic":iccard,
        @"type":type
    };
    return [self requestDataWithUrl:Auth parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
// 部门选择
- (void)bumenResultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{};
    return [self requestDataWithUrl:Bumen parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
// 获取验证码
- (void)codeuserID:(NSString *)userid mobile:(NSString *)mobile type:(NSString *)type resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userid,
        @"mobile":mobile,
        @"type":type
    };
    return [self requestDataWithUrl:SmsCode parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//会员注册
- (void)userRegisteruserID:(NSString *)userid  mobile:(NSString *)mobile section_id:(NSString *)section_id company_id:(NSString *)company_id captcha:(NSString *)captcha resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userid,
        @"mobile":mobile,
        @"section_id":section_id,
        @"company_id":company_id,
        @"captcha":captcha,
    };
    
    return [self requestDataWithUrl:Register parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//用户信息
- (void)userinfoResultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":[TokenManager getUserId],
    };
    
    return [self requestDataWithUrl:UserInfo parameters:params cacheTypeValue:kCacheValue resultBlock:block];
    // return [self  requestGetDataWithUrl:PhoneList parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//忘记密码
- (void)forgetPassuserID:(NSString *)userid  new_pass:(NSString *)new_pass captcha:(NSString *)captcha resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userid,
        @"new_pass":new_pass,
        @"captcha":captcha,
    };
    
    return [self requestDataWithUrl:ForgetPass parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//轮播图
- (void)sliderResultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"slide_type":@"wechat_home",
    };
    return [self requestDataWithUrl:Slide parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 员工诉求列表
- (void)stffListstaff_id:(NSString *)staff_id  page:(int)page status:(NSString *)status resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"page":@(page),
        @"status":status,
    };
    
    return [self requestDataWithUrl:Staff_appeal_list parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
// 归属部门诉求列表
- (void)section_main_appeal_liststaff_id:(NSString *)staff_id  page:(int)page status:(NSString *)status resultBlock:(BaseResultBlock)block{
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"page":@(page),
        @"status":status,
    };
    
    return [self requestDataWithUrl:Section_main_appeal_list parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 部门负责人诉求列表
- (void)section_normal_appeal_liststaff_id:(NSString *)staff_id  page:(int)page status:(NSString *)status resultBlock:(BaseResultBlock)block{
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"page":@(page),
        @"status":status,
    };
    
    return [self requestDataWithUrl:Section_normal_appeal_list parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//领导产看诉求列表
- (void)sectionListstaff_id:(NSString *)staff_id  page:(int)page status:(NSString *)status resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"page":@(page),
        @"status":status,
    };
    
    return [self requestDataWithUrl:Leader_normal_appeal_list parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//领导负责人诉求列表
- (void)leaderMainAppealliststaff_id:(NSString *)staff_id  page:(int)page status:(NSString *)status resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"page":@(page),
        @"status":status,
    };
    
    return [self requestDataWithUrl:Leader_main_appeal_list parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
//公告列表
- (void)noticeListParentid:(NSString *)parentid page:(int)page resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"parent_id":parentid,
        @"page":@(page)
    };
    return [self requestDataWithUrl:NoticeList parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//公告详情
- (void)getDetailNoticeID:(NSString *)noticeID  resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":noticeID,
    };
    return [self requestDataWithUrl:GetDetail parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//发展建议 投诉检举
//- (void)getInfoPoststaff_id:(NSString *)staff_id type:(NSString *)type content:(NSString *)content name:(NSArray *)name work_address:(NSArray *)work_address photo_name:(NSArray *)photo_name photo_urls:(NSArray *)photo_urls resultBlock:(BaseResultBlock)block {
//    NSDictionary *params = @{
//        @"staff_id":staff_id,
//        @"type":type,
//        @"content":content,
//        @"more[name]":name,
//        @"more[work_address]":work_address,
//        @"photo_names":photo_name,
//        @"photo_urls":photo_urls,
//    };
//    return [self requestDataWithUrl:InfoPost parameters:params cacheTypeValue:kCacheValue resultBlock:block];
//}

- (void)getInfoPoststaff_id:(NSString *)staff_id type:(NSString *)type content:(NSString *)content name:(NSString *)name work_address:(NSString *)work_address photo_name:(NSArray *)photo_name photo_urls:(NSArray *)photo_urls resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"type":type,
        @"content":content,
        @"name":name,
        @"work_address":work_address,
        @"photo_names":photo_name,
        @"photo_urls":photo_urls,
    };
    return [self requestDataWithUrl:InfoPost parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 上传图片
- (void)upLoadImageimageArray:(NSArray *)imageArray resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{};
    return [self upLoadMultiFileWithUrl:UpLoadImage parameters:params imageArray:imageArray resultBlock:block];
}

//办理诉求详情
- (void)admin_appeal_detailID:(NSString *)suqID staff_id:(NSString *)staff_id auth:(NSString *)auth resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
         @"id":suqID,
         @"staff_id":staff_id,
         @"auth":auth,
    };
    return [self requestDataWithUrl:Admin_appeal_detail parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
//员工诉求详情
- (void)staff_appeal_detailID:(NSString *)suqID  resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":suqID,
    };
    return [self requestDataWithUrl:Staff_appeal_detail parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
//诉求类型
- (void)appealTypeResultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{};
    return [self requestDataWithUrl:AppealType parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}


//发布诉求
- (void)appealPoststaff_id:(NSString *)staff_id type:(NSString *)type content:(NSString *)content photo_name:(NSArray *)photo_name photo_urls:(NSArray *)photo_urls resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"type":type,
        @"content":content,
        @"photo_names":photo_name,
        @"photo_urls":photo_urls,
    };
    return [self requestDataWithUrl:AppealPost parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//诉求办理
- (void)appealFlowPostAppeal_id:(NSString *)appeal_id user_id:(NSString  *)user_id receive_id:(NSString *)receive_id status:(NSString *)status content:(NSString *)content last_step:(NSString *)last_step photo_name:(NSArray *)photo_name photo_urls:(NSArray *)photo_urls auth:(NSString *)auth resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"appeal_id":appeal_id,
        @"user_id":user_id,
        @"receive_id":receive_id,
        @"status":status,
        @"content":content,
        @"last_step":last_step,
        @"photo_names":photo_name,
        @"photo_urls":photo_urls,
        @"auth":auth,
    };
    return [self requestDataWithUrl:AppealFlowPost parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
//发送领导
- (void)getLeadersstaff_id:(NSString *)staff_id resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
    };
    return [self requestDataWithUrl:GetLeaders parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
// 发送科室
- (void)getSectionsstaff_id:(NSString *)staff_id resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
    };
    return [self requestDataWithUrl:GetSections parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 员工诉求详情
- (void)staffAppealDetailID:(NSString *)staff_id resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":staff_id,
    };
    return [self requestDataWithUrl:StaffAppealDetail parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 诉求评价
- (void)appraiseParent_id:(NSString *)parent_id  staff_id:(NSString *)staff_id type:(NSString *)type content:(NSString *)content resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"parent_id":parent_id,
        @"staff_id":staff_id,
        @"type":type,
        @"content":content,
    };
    return [self requestDataWithUrl:Appraise parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 待办数字显示
- (void)appealUntreatedNumStaff_id:(NSString *)staff_id role_id:(NSString *)role_id resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"staff_id":staff_id,
        @"role_id":role_id,
    };
    return [self requestDataWithUrl:AppealUntreatedNum parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 流程步骤
- (void)appealFlowChartId:(NSString *)appealID  resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":appealID,
    };
    return [self requestDataWithUrl:AppealFlowChart parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

//修改部门
- (void)editSectionid:(NSString *)userID  company_id:(NSString *)company_id section_id:(NSString *)section_id captcha:(NSString *)captcha resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userID,
        @"company_id":company_id,
        @"section_id":section_id,
        @"captcha":captcha,
    };
    return [self requestDataWithUrl:EditSection parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

// 修改手机号
- (void)editMobileid:(NSString *)userID  pass:(NSString *)pass mobile:(NSString *)mobile captcha:(NSString *)captcha resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userID,
        @"pass":pass,
        @"mobile":mobile,
        @"captcha":captcha,
    };
    return [self requestDataWithUrl:EditMobile parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
// 修改密码
- (void)editPassid:(NSString *)userID  old_pass:(NSString *)old_pass new_pass:(NSString *)new_pass captcha:(NSString *)captcha resultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{
        @"id":userID,
        @"old_pass":old_pass,
        @"new_pass":new_pass,
        @"captcha":captcha,
    };
    return [self requestDataWithUrl:EditPass parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}
//热线电话
- (void)getHotTelResultBlock:(BaseResultBlock)block {
    NSDictionary *params = @{};
    return [self requestDataWithUrl:GetHotTel parameters:params cacheTypeValue:kCacheValue resultBlock:block];
}

@end
